import { defineStore } from "pinia";

export const useInfoStore = defineStore({
  id: "info",
  state: () => ({
    deviceNo: '',
    loginStatus: '',
    deviceStatus: "-1",
    bleStatus: '0',
    bleName: '',
    // 0-空闲,1-拨号中，2-来电中，3-已接通
    deviceUseStatus: '0',
    wsIsClose: false,//webSocket是否关闭连接
    // 最后一次通话号码,
    lastCall: [{
      deviceNo: '',
      phone: ''
    }],
    //现在需要拨打的号码
    nowCall: '',
    phoneName: '', //电话号名字
    customPhone: null, //自定义协议带过来的号码
    isTime:false
  }),
  actions: {
    SET_deviceNo(deviceNo) {
      this.deviceNo = deviceNo;
    },
    SET_loginStatus(loginStatus) {
      this.loginStatus = loginStatus;
    },
    SET_deviceStatus(deviceStatus) {
      // console.log('存设备状态');
      this.deviceStatus = deviceStatus;
    },
    SET_bleName(bleName) {
      this.bleName = bleName;
    },
    SET_deviceUseStatus(deviceUseStatus) {
      
      this.deviceUseStatus = deviceUseStatus;
    },
    SET_wsIsClose(bool) {
      this.wsIsClose = bool;
    },
    SET_lastCall(phone) {
      this.lastCall.push(phone);
    },
    SET_nowCall(phone) {
      // console.log(phone,'storePhone');
      this.nowCall = phone;
    },
    SET_phoneName(phoneName) {
      this.phoneName = phoneName;
    },
    SET_bleStatus(status) {
      this.bleStatus = status;
    },
    SET_customPhone(customPhone) {
      console.log('调用自定义',customPhone);
      this.customPhone = customPhone;
    },
    SET_isTime(isTime) {
      this.isTime = isTime;
    },
    persist: true
  },
});
